#define _CRT_SECURE_NO_WARNINGS 1

#include<iostream>
#include"myUnique.h"


struct Foo {
	int x;
	Foo(int v = 0) : x(v) { std::cout << "Foo(" << x << ") constructed\n"; }
	~Foo() { std::cout << "Foo(" << x << ") destroyed\n"; }
	void hello() const { std::cout << "Hello from Foo(" << x << ")\n"; }
};

int main() {
	{
		auto p = make_unique<Foo>(42);
		p->hello();

		// move
		myUniquePtr<Foo> q = std::move(p);
		if (!p) std::cout << "p is null after move\n";
		q->hello();

		// release
		Foo* raw = q.release();
		if (!q) std::cout << "q is null after release\n";
		raw->hello();
		delete raw; // manual delete after release

		// reset
		myUniquePtr<Foo> r(new Foo(7));
		r.reset(new Foo(8)); // should destroy Foo(7)
	}
	std::cout << "exiting main\n";
	return 0;
}
